package com.frank.practice.rpc;

import com.frank.auth.api.UserFeignService;
import com.frank.auth.entity.AuthUserDto;
import com.frank.common.entity.Result;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Frank Zou
 * @version v0.0.1
 * @date 2025/7/4
 * @description
 */
@Component
public class UserRpc {

    @Resource
    private UserFeignService userFeignService;

    /**
     * 获取用户信息
     * @param username 用户名
     * @return 用户信息
     */
    public AuthUserDto getUserInfo(String username) {
        Result<AuthUserDto> userInfo = userFeignService.getUserInfo(username);
        if (!userInfo.getSuccess()) {
            return new AuthUserDto();
        }
        return userInfo.getData();

    }
}
